﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Supersense.db;

public partial class _Default : System.Web.UI.Page
{
    public DataTable dt;
    public DataTable productCategory;
    public DataTable[] ds;
    public DataTable tops;
    public DataTable topsSolution;
    protected void Page_Load(object sender, EventArgs e)
    {

        Crud category = new Crud("ss_category");
        DataTable subCategory = category.fList("type='product' and upid!=0", "", "", "");
        productCategory = category.fList("type='product' and upid=0", "", "", "");
        productCategory.Columns.Add("subCategory");
        Crud modelProduct = new Crud("ss_product", "id");
        ds = new DataTable[productCategory.Rows.Count];
        for (int i = 0; i < productCategory.Rows.Count; i++)
        {
            if (productCategory.Rows[i]["id"].ToString() == "6")
            {
                ds[i] = modelProduct.fList("catid=42", "", "4", "");
            }
            else
            {
                ds[i] = modelProduct.fList("type=" + productCategory.Rows[i]["id"].ToString(), "", "4", "");
            }
            
        }
        DataRow dr1 = ds[6].Rows[0];
        ds[1].Rows.Add(dr1.ItemArray);
        dr1 = ds[6].Rows[1];
        ds[1].Rows.Add(dr1.ItemArray);
        ds[7].Rows.Add(ds[1].Rows[1].ItemArray);
        Crud modelSolution = new Crud("ss_spacenews", "id");
        dt = modelSolution.fList("type='solution'", "settop desc,dateline desc", "", "");

        tops = modelProduct.fList("tops=1", "", "", "");
    }

    public Hashtable dealTable(DataTable sourceTable, String key, String value)
    {
        Hashtable ht = new Hashtable();
        foreach (DataRow dr in sourceTable.Rows)
        {
            if (dr[key] == value)
            {
                ht.Add("name",dr["name"]);
                ht.Add("id", dr["id"]);
            }
        }
        return ht;
    }
}